﻿// --------------------------------------------------------------------------------------------------------------------- 
// <copyright file="Fibonacci.cs" company="Microsoft">
//   Copyright (c) Microsoft Corporation.  All rights reserved. THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR PURPOSE.
// </copyright>
// <summary>
//   Defines the Fibonacci type.
// </summary>
// ---------------------------------------------------------------------------------------------------------------------
namespace EulerProblemsCSharp
{
    using System.Collections.Generic;
    using Microsoft.FSharp.Math;

    /// <summary>
    /// Generates numbers in the Finonacci sequence.
    /// </summary>
    public class Fibonacci
    {
        /// <summary>
        /// Gets integers from the Fibonacci sequence.
        /// </summary>
        /// <returns>
        /// IEnumerable of int.
        /// </returns>
        public IEnumerable<int> Sequence
        {
            get
            {
                var a = 0;
                var b = 1;
                var c = a + b;

                while (true)
                {
                    yield return c;

                    c = a + b;
                    a = b;
                    b = c;
                }                         
            }
        }

        /// <summary>
        /// Gets BigInts from the Fibonacci sequence. 
        /// </summary>
        /// <returns>
        /// IEnumerable of BigInt.
        /// </returns>
        public IEnumerable<BigInt> BigSequence
        {
            get
            {
                var a = BigInt.Zero;
                var b = BigInt.One;
                var c = a + b;

                while (true)
                {
                    yield return c;

                    c = a + b;
                    a = b;
                    b = c;
                }                
            }
        }
    }
}